package com.hkts.management.unattended.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassNameFanoutRabbitConfig
 * @Description
 * @Author yck
 * @Date2021-07-16 15:21
 * @Version V1.0
 **/

@Configuration
public class FanoutRabbitConfig {
    /**
     *  创建三个队列 ：fanout.A   fanout.B  fanout.C
     *  将三个队列都绑定在交换机 fanoutExchange 上
     *  因为是扇型交换机, 路由键无需配置,配置也不起作用
     */
    //exchange name
    public static final String UNATTENDED = "unattendedExchange";
    //司机往货主端推送模板消息
    public static final String Unattended_Queue_Name = "unattended.queue";

    @Bean
    public Queue queueUnattended() {
        return new Queue(Unattended_Queue_Name);
    }


    @Bean
    FanoutExchange unattendedExchange() {
        return new FanoutExchange(UNATTENDED);
    }
    @Bean
    Binding unattendedExchangeReminders() {
        return BindingBuilder.bind(queueUnattended()).to(unattendedExchange());
    }
}